

<template>
  <div>
    <page :asideShow="asideShow">
      <div slot="toolbar">
        <el-form :inline="true" :model="filters" label-width="90px" label-position="right">
          <!-- <el-form-item label="审核状态：">
            <el-select v-model="filters.status" placeholder="请选择" clearable>
              <el-option
                v-for="item in personType"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item> -->
          <el-form-item label="姓名：">
            <el-input class="normal" placeholder="请输入" clearable v-model="filters.name"></el-input>
          </el-form-item>
          <el-form-item label="选择小区:">
            <el-select v-model="filters.CID" filterable placeholder="请选择" clearable>
              <el-option
                v-for="item in getCommunity"
                :key="item.CID"
                :label="item.name"
                :value="item.CID"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="handleQuery">查询</el-button>
          </el-form-item>
        </el-form>
      </div>
      <div slot="content">
        <el-table
          ref="selectBox"
          :data="pageResult"
          stripe
          v-loading="loading"
          style="width: 100%;"
          element-loading-text="加载中..."
        >
      
          <el-table-column
            prop="name"
            header-align="center"
            align="center"
            label="姓名"
            show-overflow-tooltip
          >
            <!-- <template slot-scope="scope">
              <span>{{scope.row.name ? scope.row.name : "/"}}</span>
            </template> -->
          </el-table-column>
          <el-table-column prop="cname" label="小区" align="center">
            <!-- <template slot-scope="scope">
              <span>{{scope.row.perName ? scope.row.perName : "/"}}</span>
            </template> -->
          </el-table-column>
          <el-table-column prop="insertTime" label="开门时间" align="center">
            <!-- <template slot-scope="scope">
              <span>{{scope.row.idCardS ? scope.row.idCardS : "/"}}</span>
            </template> -->
          </el-table-column>
          <el-table-column prop="methods" label="开门方式" align="center" show-overflow-tooltip>
            
          </el-table-column>

         
          
        </el-table>
      </div>
      <div slot="footer">
        <el-pagination
          layout="total, prev, pager, next, jumper"
          @current-change="refreshPageRequest"
          :current-page="pageRequest.page"
          :page-size="pageRequest.limit"
          :total="totalSize"
          style="float:right;"
        ></el-pagination>
      </div>
    </page>
  </div>
</template>

<script>
import { format } from "@/utils/datetime";
export default {
  data() {
    return {
      loading: false,
      // 审核状态
      personType: [
        // { label: "审核中", value: 2 },
        { label: "审核通过", value: 1 },
        { label: "审核未通过", value: 0 }
      ],
      imgs: require("@/assets/imgs/houtai/wutu.png"),
      asideShow: false,
      unitShow: false,
      pageResult: [],
      filters: {
        corpId: 0,
        corpName: "",
        username: "",
        startTime: "",
        endTime: "",
        status: "",
        CID:'',
      },
        getCommunity: [],
      pageRequest: {
        page: 1,
        limit: 10
      },
      columns: [],
      totalSize: 0
    };
  },
  mounted() {
    this.getlist();
    this.getCommunityList();
  },
  methods: {
    getlist() {
      this.loading = true;
      let params = Object.assign(this.pageRequest,this.filters);
      let paramJson = JSON.stringify(params);

      this.$api.openDoor.openDoorList(paramJson).then(res => {
      
        if (res.code == 0) {
          this.loading = false;
          this.totalSize = res.count;
          let dataList=res.data
          dataList.map(item =>{
              item.cname=item.community[0].name
            //   item.name=item.person[0].name
              item.insertTime=this.$format(item.insertTime)
              item.methods='远程开门'
          })

          this.pageResult = dataList;
         
          
        } else {
          this.loading = false;
        }
      });
    },
    // 小区查询
  //获取小区的列表选择器
    getCommunityList() {
      let params = {};

      params = {
        where: {
          CODES: []
        }
      };

      let param = JSON.stringify(params);
      this.loading = true;
      this.$api.three.communityList(params).then(res => {
        if (res.code == 0) {
          this.loading = false;
          this.getCommunity = res.data;
          // this.totalSize = res.count;
          // this.pageResult.map(item => {
          //   item.insertTime = this.$format(item.insertTime);

          // });
        } else {
          this.$message({ message: "操作失败, " + res.msg, type: "error" });
        }
      });
    },
    // 翻页
    refreshPageRequest(page) {
      this.pageRequest.page = page;
      this.getlist();
    },
    //查询
    handleQuery() {
      this.getlist();
    }
  }
};
</script>

<style>
</style>